package com.its.search.controller;

import com.its.domain.BaseResult;
import com.its.search.domain.GoodsSearchParam;
import com.its.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SearchController {
    //声明业务层属性
    @Autowired
    private SearchService searchService;

    //搜索条件自动补全功能
    @GetMapping("/user/goodsSearch/autoSuggest")
    public BaseResult autoSuggest(String keyword){
        return BaseResult.ok(searchService.autoSuggest(keyword));
    }
    /*
     * 搜索商品
     * */
    @PostMapping("/user/goodsSearch/search")
    public BaseResult searchGoods(@RequestBody GoodsSearchParam param){
        return BaseResult.ok(searchService.searchGoodsService(param));
    }
}
